package cn.pugle.base;

import java.util.Random;
import java.util.regex.Pattern;

/**
 * Created by tzp on 15-10-8.
 * 转义字符 及 String.replaceAll replace问题
 */
public class EscapeCharTest {
    public static void main(String[] args) {

        int[] iar = new int[]{1, 2, 3};


        String s = "a\tb";
        System.out.println(s.split(Pattern.quote("\\t")).length);
        System.out.println(new Random().nextInt() % 3);
        charCode();


    }

    public static void charCode() {
        System.out.println('\u00FE');
        System.out.println(Character.getName(0x00FE));
        System.out.println(Character.toChars(0x00FE).length);
        char c = 'þ';
        System.out.println((int) c);
        System.out.println((char) 254);
        System.out.println('\002');
        System.out.println((char) 254);
        char[] cs = new char[]{'a', '\u0002', 'b'};
        String s = new String(cs);
        System.out.println(cs);
    }
//    在代码里String字面量需要转义再转义是因为字面量要双引号包围,而在文件里就不需要了!
//    FieldConfig fieldConfig = new FieldConfig();
//    fieldConfig.location = "a\n";
//    String s = JSON.toJSON(fieldConfig).toString();
//    System.out.println(s);
//    String ss = "{\"location\":\"a\\n\",\"regexGroupIndex\":0,\"sepIndex\":0}";
//    String sss = FileUtils.readFileToString(new File("/home/tzp/projects/charm/src/main/resources/escape.json"));
//    FieldConfig fieldConfig1 = JSON.parseObject(sss, FieldConfig.class);
//    System.out.println(fieldConfig1.location);
}
